/**
 * Created with intelliJ IDEA.
 * Description:
 * User:常亚洁
 * Date:20250921
 * Time:14:19
 */
class Student{

    //字段   属性    成员变量 ；定义在类当中，方法的外边
    private String name;
    private String sutNum;//学号
    private int age;
    public static String className;//班级
    //被static修饰的成员，不属于对象   static不依赖对象，不需要实例化对象
    public String getName(){
        return name;
    }

    //成员方法
public void eat(){
    System.out.println(this.name+"正在吃饭....");
}

    public void setName(String name) {
        this.name = name;
    }

    public String getSutNum() {
        return sutNum;
    }

    public void setSutNum(String sutNum) {
        this.sutNum = sutNum;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void doClass(){
    System.out.println(this.name+"正在上课.....");
}
//如果当前类的没有任何构造方法，Java会帮你提供一个构造方法
public Student(){
    this("zhangsan","2024101240",15);
    System.out.println("不带参数的构造方法.....");
}
/*
public Student(String sutNum,String name,int age){
    this.sutNum=sutNum;
    this.name=name;
    this.age=age;
    System.out.println("调用了带有三个参数的构造方法...");
}
*/


    public Student(String name, String sutNum, int age) {
        this.name = name;
        this.sutNum = sutNum;
        this.age = age;
    }
    public void show(){
        System.out.println("姓名："+this.name+"学号："+this.sutNum+"年龄："+this.age);
    }
}

public class Test {

    public static void main(String[] args) {
        Student student1 =new Student("2024101250","里斯",14);
      //  student1.className="一班";这是通过对象来访问
        student1.show();
        Student student2 =new Student("2024102125","张三",15);
     //   student2.className="一班";
        student2.show();
        Student.className="1班";//通过类名来访问，建议通过类名来访问
    }
    public static void main1(String[] args) {
        //对象的实例化，通过new
        Student student1 =new Student();
        student1.setName(("张三"));
        student1.setAge(15);
        student1.setSutNum("2024101256");
        student1.eat();
        student1.doClass();
        System.out.println( student1.getName());
        System.out.println(student1.getAge());
        System.out.println(student1.getSutNum());


        System.out.println("=====================");


        Student student2 =new Student();
        student2.setName("里斯");
        student2.setAge(15);
        student2.setSutNum("2024101266");
        System.out.println(student2.getName());
        System.out.println(student2.getAge());
        System.out.println(student2.getSutNum());
    }
}
